/*
 *  Definitions for Command Processor
 */
#ifndef __COMMAND_H
#define __COMMAND_H

#ifndef NULL
#define NULL	0
#endif

/* Default to a width of 8 characters for help message command width */
#ifndef CONFIG_SYS_HELP_CMD_WIDTH
#define CONFIG_SYS_HELP_CMD_WIDTH	8
#endif

#undef	CONFIG_MAX_CMD_SIZE
#define	CONFIG_MAX_CMD_SIZE			20

/*
 * Monitor Command Table
 */

struct cmd_tbl_s {
    char		*name;		/* Command Name			*/
    int		maxargs;	/* maximum number of arguments	*/
    /* Implementation function	*/
    int		(*cmd)(struct cmd_tbl_s *, int, char *[]);
    char		*usage;		/* Usage message	(short)	*/
    char		*help;		/* Help  message	(long)	*/
};

typedef struct cmd_tbl_s	cmd_tbl_t;

extern cmd_tbl_t *cmd_start;
extern cmd_tbl_t *cmd_end;

extern cmd_tbl_t cmd_group[CONFIG_MAX_CMD_SIZE];

/* src/TCR_Commnad.c */
int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int argc, char *argv[]);
cmd_tbl_t *find_cmd(const char *cmd);
cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len);

extern int cmd_usage(cmd_tbl_t *cmdtp);
extern int cmd_init();
/*
 * Monitor Command
 *
 * All commands use a common argument format:
 *
 * void function (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 */

typedef	void	command_t (cmd_tbl_t *, int, int, char *[]);

#define U_BOOT_CMD(cmdtp, para_name, para_maxargs, para_cmd, para_usage, para_help) do{	   \
    cmdtp.name = #para_name;   \
    cmdtp.maxargs = para_maxargs;	  \
    cmdtp.cmd = para_cmd;     \
    cmdtp.usage = para_usage;	  \
    cmdtp.help = para_help;	  \
    }while(0)

#endif	/* __COMMAND_H */
